/**
* 版权声明：厦门睿商网络科技有限公司 版权所有 违者必究
* 日    期：2020-02-17
*/
package com.rzico.basics.controller.member;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.rzico.annotation.Log;
import com.rzico.base.BaseController;
import com.rzico.base.CommResult;
import com.rzico.basics.entity.Member;
import com.rzico.basics.service.EnterpriseService;
import com.rzico.basics.service.MemberFavoritesService;
import com.rzico.basics.service.MemberService;
import com.rzico.basics.service.MemberTraceService;
import com.rzico.entity.PageResult;
import com.rzico.entity.Pageable;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 分销接口
 *
 * @author Rzico Boot
 * @version 1.0
 * @date 2020-02-17
 */
@Api(description = "分销接口")
@RestController
@RequestMapping("/member/promoter")
public class PromoterMemberController extends BaseController {

    protected Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private MemberService memberService;

    @ApiOperation("统计分销业绩")
    @GetMapping(value = "/summary")
    public CommResult<Member> getInfo(HttpServletRequest request) {
        CommResult commResult = new CommResult();
        Member member = memberService.getCurrent();
        Map<String, Object> data = new HashMap<>();
        //推广人数
        Map<String,Object> params = new HashMap<>();
        params.put("promoterId",member.getId());
        Integer mb = memberService.selectRowCount(params);
        data.put("member",mb);
        //分润收入
        data.put("rebate",memberService.summaryRebate(member));
        //推广订单
        data.put("order",memberService.summaryOrder(member));
        commResult.setData(data);
        return commResult;
    }


}
